<?php

  require_once "JooS/Server/Resource/DataContent.php";

  class JooS_Server_Resource_DataText extends JooS_Server_Resource_DataContent {
    public function __construct($name, $value) {
      parent::__construct($name);
      parent::__set("nodeValue", $value);
    }

    public function __get($name) {
      switch ($name) {
        case "value":
          return $this->getNodeValue();
        case "name":
          return $this->getNodeName();
        case "nodeValue":
          $nodeValue = parent::__get($name);
          $text = $this->getNodeValue();
          if (strlen($text))
            $nodeValue[] = $text;
          return $nodeValue;
        case "nodeType":
          return self::DATA_TEXT_NODE;
        default:
          return parent::__get($name);
      }
    }

    public function __isset($name) {
      switch ($name) {
        case "name":
        case "value":
          return true;
        default:
          return parent::__isset($name);
      }
    }

    public function __unset($name) {
      switch ($name) {
        case "value":
        case "nodeValue":
          $this->nodeValue = "";
          break;
        case "name":
          break;
        default:
          parent::__unset($name);
          break;
      }
    }
  }

?>